Skip to content

feat(exec): add --privileged and --data-env flags#570

Merged
davidsu merged 3 commits into
mainfrom
feat/exec-privileged-data-env
Jul 23, 2026
Merged

feat(exec): add --privileged and --data-env flags#570
davidsu merged 3 commits into
mainfrom
feat/exec-privileged-data-env

Conversation

@davidsu

@davidsu davidsu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Note

Description

Adds two new flags to the base44 exec command: --privileged and --data-env. --privileged runs the script with admin privileges by sending the X-Bypass-RLS header (bypassing row-level security), and --data-env <environment> targets a specific data environment via the X-Data-Env header. This lets users run one-off scripts against different data environments and with elevated access when their role permits.

Related Issue

Ported from #435

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added --privileged and --data-env <environment> options to the exec command, including help text and a usage example.
  • Threaded privileged and dataEnv through runScript() (RunScriptOptions), forwarding them to the Deno subprocess as the BASE44_PRIVILEGED and BASE44_DATA_ENV environment variables.
  • Updated the Deno runtime (deno-runtime/exec.ts) to read those env vars and attach the X-Bypass-RLS and X-Data-Env headers to the SDK client when set.
  • Added integration tests covering header presence/absence for both flags.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The --privileged flag requires the caller to have an app owner/editor role; enforcement is handled server-side via the X-Bypass-RLS header. Both headers are only sent when the corresponding flag is provided.


🤖 Generated by Claude | 2026-07-23 08:57 UTC | 3e2e87e

Faithful port of #435 (Netanel Gilad) with the renamed flags:
- --privileged sends the X-Bypass-RLS header (bypass RLS)
- --data-env <environment> sends the X-Data-Env header

Both flow exec.ts -> run-script.ts (BASE44_PRIVILEGED / BASE44_DATA_ENV
env vars) -> the Deno wrapper, which builds the SDK request headers.

Open backend questions surfaced during review (RLS-bypass exposure and
prod-edge survival, data-env value validation, and data-env scope for
backend-function invocations) are flagged inline as QUESTION(@netanelgilad)
comments for Netanel to resolve at review.

Refs #435

Co-Authored-By: Netanel Gilad <netanelg@wix.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.5-pr.570.3e2e87e

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.5-pr.570.3e2e87e"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.5-pr.570.3e2e87e"
  }
}

Preview published to npm registry — try new features instantly!

Netanel's calls: no CLI-side value validation (server's job), and the
backend-function invocation scope is a backend concern, not the CLI's.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidsu
davidsu force-pushed the feat/exec-privileged-data-env branch from 38ed231 to 2d38b3f Compare July 23, 2026 07:50
The X-Bypass-RLS header is gated to editors server-side in EntityCRUD
(_verify_admin_permissions); no CLI-side concern remains.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidsu
davidsu merged commit 057329a into main Jul 23, 2026
13 checks passed
@davidsu
davidsu deleted the feat/exec-privileged-data-env branch July 23, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants